
#ifndef GLOBAL_H
#define GLOBAL_H

#include "Typedefine.h"
#include "project.h"
#include "Psoc4_dgc.h"
    
    
#define __RESET_WATCHDOG()   CySysWdtClearInterrupt() 


#define FrzSet_RealUpLimit    (8)
#define FrzSet_RealDownLimit  (-30)
#define FrzSet_UpLimit        (FrzSet_RealUpLimit - FrzSet_RealDownLimit)
 
#define FrzRealSetToSet(realSet)   ((realSet) - FrzSet_RealDownLimit)

#define FrzSetToReal(set)   (set +  FrzSet_RealDownLimit)


extern uchar u8_FuncRefSetTemp;
extern uchar u8_FuncFrzSetTemp;
extern uchar u8_FuncTeaSetTemp;
extern uchar u8_FuncFFrzSetTemp;
extern uchar u8_FuncDeepFrzSetTemp;
extern uchar u8_FuncMilkSetTemp;
    
extern  uchar R_BuzzTime1ms; // 110428 
extern  uchar R_BuzzCnt; 
extern  uchar R_E2WriteTime1ms ; // 110428    
extern  uchar u8_PowerOnHalfSec;                        // 131114 
extern  uchar u8_TestToDisp;  
extern  uchar u8_Millisec;    
 
#define REF_DEFAULT        FrzRealSetToSet(4)
#define FRZ_DEFAULT        FrzRealSetToSet(-18)
#define TEA_DEFAULT        FrzRealSetToSet(5)
#define FFR_DEFAULT        FrzRealSetToSet(-22)
#define DEEPFRZ_DEFAULT     FrzRealSetToSet(-30)
#define MILK_DEFAULT        FrzRealSetToSet(-20)

#define REF_UPLIMIT      FrzRealSetToSet(8)
#define REF_DOWNLIMIT    FrzRealSetToSet(2)
#define FRZ_UPLIMIT      FrzRealSetToSet(-1)
#define FRZ_DOWNLIMIT    FrzRealSetToSet(-24)
    
#define MODE_REF      1
#define MODE_FRZ      2
#define MODE_TEA      3
#define MODE_SUPERFRZ 4
#define MODE_DEEPFRZ  5 
#define MODE_MILK     6    

#define SET 1
#define CLEAR 0
#define ON 1
#define OFF 0
#define ALL_LIGHT  ON
#define NO_LIGHT   OFF
#define CON_SendBitNum 8
#define CON_SendByteNum 12
#define CON_SendBuzzByteNum 1
#define CON_InitStatusValue		0x55
#define CON_NormalStatusValue	0xAA
#define CON_SpecialStatusValue	0x5A
#define CON_RecBitNum 8
#define CON_RecByteNum 12 // 110428 
#define CON_RecBuzzByteNum 1
//#define TXIE SSR_TIE
#define CON_MaxSendByte 85
#define CON_MaxRecByte 15

//#define f_J1      flagState.Bits.BIT0   
//#define f_J2      flagState.Bits.BIT0 
extern _Bool f_J1;
extern _Bool f_J2;    
  
//#define f_HalfSec           flagState0.Bits.BIT0
extern _Bool f_HalfSec;
    
//extern  MachineParameter_st str_MachineParameter;

#define u8_FreezerSet                  	str_MachineParameter.FreezerSet
#define flagState1                 		str_MachineParameter.FlagState1.Byte
#define flagState2                 		str_MachineParameter.FlagState2.Byte

#define f_SuperFrz            	str_MachineParameter.FlagState1.Bits.BIT0
#define f_E2Defrost           	str_MachineParameter.FlagState1.Bits.BIT1
#define f_DisplayMode			str_MachineParameter.FlagState1.Bits.BIT2 //演示模式

    
    
    
//#define f_RecOK             flagState.Bits.BIT0
//#define f_PowerOff          flagState.Bits.BIT1
//#define f_SendBuzz          flagState.Bits.BIT2
//#define f_SendOK            flagState.Bits.BIT3
//#define f_ComOK             flagState.Bits.BIT4
    
extern _Bool f_RecOK;
extern _Bool f_PowerOff ;
extern _Bool f_SendBuzz ;
extern _Bool f_SendOK ;
extern _Bool f_ComOK ; 
extern _Bool f_FirstAd;
extern _Bool f_RecInitFrame;
extern _Bool f_SendNewFrame  ;
extern _Bool f_SendPortHigh  ;
extern _Bool f_SendData      ;
extern _Bool f_SendBitState  ;
extern _Bool f_SendingBuzz   ;
extern _Bool f_RecPortLow    ;
extern _Bool f_RecData       ;
extern _Bool f_RecBuzz       ;
     
//#define F_E2NeedWrite       flagState1.Bits.BIT0
//#define F_E2WriteWait       flagState1.Bits.BIT1
//#define F_DoubleBi          flagState1.Bits.BIT2
//#define F_SingleBi          flagState1.Bits.BIT3 //
    
extern _Bool f_NeedWriteE2   ;
extern _Bool f_E2WriteWait ;
extern _Bool F_DoubleBi    ;
extern _Bool F_SingleBi    ;   

//extern  BitType flagState;
//#define f_CompFirstOnFre    flagState.Bits.BIT0     // 111213 
//#define f_FirstChkFrzHigh   flagState.Bits.BIT1
//#define f_SingleBp          flagState.Bits.BIT3
//#define f_DoubleBp          flagState.Bits.BIT4
//#define f_TestStatus        flagState.Bits.BIT5           // 上电  PULLDOWN
//#define f_DoorAlarm         flagState.Bits.BIT6
//#define f_BackLight         flagState.Bits.BIT7
extern _Bool  f_CompFirstOnFre  ;
extern _Bool  f_FirstChkFrzHigh ;
extern _Bool  f_SingleBp         ;
extern _Bool  f_DoubleBp        ;
extern _Bool  f_TestStatus       ;           // 上电  PULLDOWN
extern _Bool  f_DoorAlarm        ;
extern _Bool  f_BackLight        ;
    
//#define f_Lock                flagState3.Bits.BIT0    
//#define f_HalfSecDisp         flagState3.Bits.BIT1
//#define f_HalfSecFlash        flagState3.Bits.BIT2  
//#define f_LcdFirstDisp        flagState3.Bits.BIT3  
extern  _Bool f_Lock;    
extern  _Bool f_HalfSecDisp  ;
extern  _Bool f_HalfSecFlash  ;  
extern  _Bool f_LcdFirstDisp  ;     
/////Err
 
extern _Bool  f_Inlignt;    
extern _Bool  f_FrzAdjust;
extern _Bool  f_FunctionAdjust;   

#if(1)
extern _Bool  f_FrzSnrErr     ;    
extern _Bool  f_RoomSnrErr     ;
extern _Bool  f_DefSnrErr      ;
extern _Bool  f_DefFunkErr     ;
extern _Bool  f_FrzFanErr		;
extern _Bool  f_CommErr        ;
extern _Bool  f_DispRecErr     ;
extern _Bool  f_FrzHighAlarm   ;
#endif
    
#if(0)    
extern  BitType flagErrs1;                        // 111208 
#define f_MainRecErr      flagErrs1.Bits.BIT0
#define f_DispRecErr      flagErrs1.Bits.BIT1
#define f_RoomSnrErr     flagErrs1.Bits.BIT2 
#define f_CommErr        flagErrs1.Bits.BIT3
#endif
#if(0)
 extern  BitType flagErrs1;
#define  f_FrzSnrErr      	flagErrs1.Bits.BIT0
#define  f_RoomSnrErr       flagErrs1.Bits.BIT1
#define  f_DefSnrErr      	flagErrs1.Bits.BIT2
#define  f_DefFunkErr       flagErrs1.Bits.BIT3
#define  f_FrzFanErr		flagErrs1.Bits.BIT4
#define  f_CommErr          flagErrs1.Bits.BIT5
#define  f_DispRecErr       flagErrs1.Bits.BIT6
#define  f_FrzHighAlarm     flagErrs1.Bits.BIT7
#endif

#if(0)
 extern  BitType flagRec1;
#define f_RecDefrost      flagRec1.Bits.BIT0
#define f_RefDoor         flagRec1.Bits.BIT1
//#define f_RTOver65        flagRec1.Bits.BIT2
#define f_ReqSFrzOff      flagRec1.Bits.BIT3
#define f_MainRecErr      flagRec1.Bits.BIT4
#define f_FirstFrzBelowOff    flagRec1.Bits.BIT5

 extern  BitType flagState5;
#define f_RefDoorBak        flagState5.Bits.BIT0
#define f_StopDoorAlarm     flagState5.Bits.BIT1
#define f_ReqSfrzBak        flagState5.Bits.BIT2
#define f_LockBi			flagState5.Bits.BIT3
#define f_StopHighAlarm     flagState5.Bits.BIT4


 extern BitType flagSend1;
#define  f_AckScoolReq       flagSend1.Bits.BIT0
#define  f_AckSfrzReq        flagSend1.Bits.BIT1
#define  f_AckFuzzyReq       flagSend1.Bits.BIT2
#define  f_AckHolidayReq     flagSend1.Bits.BIT3
#endif

extern _Bool  f_RecDefrost        ; 
extern _Bool  f_RefDoor           ;
//extern //_Bool  f_RTOver65          ;
extern _Bool  f_ReqSFrzOff        ;
extern _Bool  f_MainRecErr        ;
extern _Bool  f_FirstFrzBelowOff  ;
extern _Bool  f_RefDoorBak        ;
extern _Bool  f_StopDoorAlarm     ;
extern _Bool  f_ReqSfrzBak        ; 
extern _Bool  f_LockBi			    ;
extern _Bool  f_StopHighAlarm     ;
extern _Bool   f_AckScoolReq      ;
extern _Bool   f_AckSfrzReq       ;
extern _Bool   f_AckFuzzyReq      ;
extern _Bool   f_AckHolidayReq     ;


#if(1)
 /*----------------first Led8------------*/
///extern     BitType      flagDispData1;
////#define f_Led18_A 		flagDispData1.Bits.BIT0
////#define f_Led18_B		flagDispData1.Bits.BIT1
////#define f_Led18_C  		flagDispData1.Bits.BIT5
////#define f_Led18_D  		flagDispData1.Bits.BIT6
////#define f_Led18_E  		flagDispData1.Bits.BIT4
////#define f_Led18_F  		flagDispData1.Bits.BIT2
////#define f_Led18_G  		flagDispData1.Bits.BIT3
//#define f_Led18_H		flagDispData1.Bits.BIT7 //"-"
    
extern _Bool f_Led18_A ;
extern _Bool f_Led18_B ;   
extern _Bool f_Led18_C ;    
extern _Bool f_Led18_D ;    
extern _Bool f_Led18_E ;    
extern _Bool f_Led18_F ;    
extern _Bool f_Led18_G ;    
    
    
    
    
    
#endif

#if(0)
extern _Bool f_Led18_A 	    ;  
extern _Bool f_Led18_B	   ;
extern _Bool f_Led18_C     ;
extern _Bool f_Led18_D     ;
extern _Bool f_Led18_E     ;
extern _Bool f_Led18_F     ;
extern _Bool f_Led18_G     ;
extern _Bool f_Led18_H     ;
#endif

#define f_Led1   f_Led18_A
#define f_Led2   f_Led18_B
#define f_Led5   f_Led18_C
#define f_Led6   f_Led18_D
#define f_Led7   f_Led18_E
#define f_Led4   f_Led18_F  
#define f_Led3   f_Led18_G
//#define f_Led15  f_Led18_H
/*----------------first Led8------------*/



/*----------------second Led8------------*/
//////extern  BitType flagDispData2;
//////#define f_Led28_A  flagDispData2.Bits.BIT0
//////#define f_Led28_B  flagDispData2.Bits.BIT1
//////#define f_Led28_C  flagDispData2.Bits.BIT5
//////#define f_Led28_D  flagDispData2.Bits.BIT6
//////#define f_Led28_E  flagDispData2.Bits.BIT4
//////#define f_Led28_F  flagDispData2.Bits.BIT2
//////#define f_Led28_G  flagDispData2.Bits.BIT3
//#define f_Led28_H  flagDispData2.Bits.BIT7  //"℃"
extern _Bool      f_Led28_A;
extern _Bool      f_Led28_B;
extern _Bool      f_Led28_C;
extern _Bool      f_Led28_D;
extern _Bool      f_Led28_E;
extern _Bool      f_Led28_F;
extern _Bool      f_Led28_G;

#define f_Led8   	    f_Led28_A
#define f_Led9   	    f_Led28_B
#define f_Led12  		f_Led28_C
#define f_Led13  		f_Led28_D
#define f_Led14  		f_Led28_E
#define f_Led11 		f_Led28_F
#define f_Led10  		f_Led28_G
//#define f_Led17   		f_Led28_H

/*----------------second Led8------------*/   
//////extern  BitType flagDispData3;
//////#define f_Led15		flagDispData3.Bits.BIT0     
//////#define f_Led16		flagDispData3.Bits.BIT1
//////#define f_Led17		flagDispData3.Bits.BIT3
//////#define f_Led18		flagDispData3.Bits.BIT2
//////#define f_Led19		flagDispData3.Bits.BIT5
//////#define f_Led20		flagDispData3.Bits.BIT6
//////#define f_Led21		flagDispData3.Bits.BIT4

 extern _Bool      f_Led15;
 extern _Bool      f_Led16;
 extern _Bool      f_Led17;
 extern _Bool      f_Led18;
 extern _Bool      f_Led19;
 extern _Bool      f_Led20;
 extern _Bool      f_Led21;

#define f_Led_Neg      f_Led15  // '-'
#define f_Led_Lock     f_Led16  // 
#define f_Led_Tempre   f_Led17  //"℃" 
#define f_Led_FFre     f_Led18 //速冻
#define f_Led_DeepFre  f_Led19 //深冻
#define f_Led_Milk     f_Led20 //母乳
#define f_Led_Tea      f_Led21 //茶  




#define f_LedMinus    f_Led_Neg
#define f_LedTunit    f_Led_Tempre

    
//////extern  BitType flagDispData4;    
//////#define f_Led22		flagDispData4.Bits.BIT0
//////#define f_Led23		flagDispData4.Bits.BIT1

 extern _Bool     f_Led22 ;
 extern _Bool     f_Led23 ;
 extern _Bool     f_Led24 ;
#define f_Led_Fre      f_Led22 //冷冻 
#define f_Led_Fridge   f_Led23 //冷藏 


#define CON_F38Degree  0
#define CON_F37Degree  10
#define CON_F35Degree  30
#define CON_F30Degree 80
#define CON_F20Degree 180
#define CON_F12Degree 260
#define CON_F10Degree 280
#define CON_F5Degree 330
#define CON_F3Degree 350
#define CON_F1Degree 370
#define CON_0Degree  380
#define CON_1Degree  390
#define CON_2Degree  400
#define CON_3Degree  410
#define CON_4Degree  420
#define CON_6Degree  440
#define CON_7Degree  450
#define CON_8Degree  460
#define CON_9Degree  470
#define CON_10Degree 480
#define CON_11Degree 490
#define CON_12Degree 500
#define CON_13Degree 510
#define CON_14Degree 520
#define CON_15Degree 530
#define CON_16Degree 540
#define CON_17Degree 550
#define CON_19Degree 570
#define CON_20Degree 580
#define CON_21Degree 590
#define CON_22Degree 600
#define CON_23Degree 610
#define CON_24Degree 620
#define CON_27Degree 650
#define CON_28Degree 660
#define CON_29Degree 670
#define CON_30Degree 680
#define CON_33Degree 710
#define CON_34Degree 720
#define CON_35Degree 730
#define CON_36Degree 740
#define CON_37Degree 750
#define CON_38Degree 760
#define CON_39Degree 770
#define CON_40Degree 780
#define CON_41Degree 790
#define CON_50Degree 880


#define CON_INVILID_FLASH   3 //操作异常时，闪烁时间 ，unitLs
#define IsHaveError      (f_RoomSnrErr || f_DefFunkErr || f_DefSnrErr || f_CommErr || f_FrzFanErr || f_FrzHighAlarm || f_FrzSnrErr)

    
#endif
